<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : stara-pekarna.xsl
    Created on : 28. duben 2011, 11:16
    Author     : Jan
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://code.google.com/p/kalkon/internalConcerts">
    <xsl:output method="xml"
                encoding="UTF-8"
                indent="yes"
                media-type="text/xml"/>

<!-- Forms concerts -->
    <xsl:template match="/html">
        <concerts>
            <xsl:apply-templates select="//div[@id='program_page']//table[@class='one_day_table'][descendant::div[@class='artist']]"/>
        </concerts>
    </xsl:template>

<!-- Parse VEVENT -->
    <xsl:template match="//table[@class='one_day_table']">
        <concert>
            <xsl:apply-templates select=".//div[@class='artist']"/>
            <description><xsl:apply-templates select=".//div[@class='artist_annotation']"/></description>
            <location>Hudební kavárna Stará Pekárna, Štefánikova 8, Brno</location>
            <xsl:apply-templates select="preceding-sibling::a[1]"/>
        </concert>
    </xsl:template>
<!-- Parse DTSTART -->
    <xsl:template match="//a[@name]">
        <day_start><xsl:value-of select="substring-after(@name,'D_')"/></day_start>
        <time_start><xsl:text>200000</xsl:text></time_start>
    </xsl:template>

<!-- Parse SUMMARY -->
    <xsl:template match="//div[@class='artist']">
        <title><xsl:apply-templates select="span[@class='artist_name']"/></title>
    </xsl:template>

    <xsl:template match="//span[@class='artist_name']">
        <xsl:value-of select="normalize-space(.)"/>
        <xsl:choose>
            <xsl:when test="following-sibling::span[@class='artist_name']"><xsl:text> + </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>


    <xsl:template match="//div[@class='artist_annotation']">
        <xsl:value-of select="normalize-space(.)"/>
        <xsl:choose>
            <xsl:when test="following-sibling::div[@class='artist_annotation']"><xsl:text>
            </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>
